package qj.tool.http;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import qj.util.IOUtil4;

/**
 * Created by QuanLA
 * Date: Mar 14, 2006
 * Time: 4:31:09 PM
 */
public class TempHttpServer {
    public static void main(String[] args) throws IOException {
        int port = 8888;
        ServerSocket ssk = new ServerSocket(port);
        System.out.println("Listening on port " + port);
        Socket sk = null;
        while (true) {
            try {
                sk = ssk.accept();
                IOUtil4.connect(sk.getInputStream(), System.out);
                sk.close();
//                HttpMessage httpMessage = HttpUtil.getHTTPMessage(sk.getInputStream()); //***
//                System.out.print(httpMessage.getHeader(true));
//                System.out.write(httpMessage.getContent());
//                PrintStream printStream = new PrintStream(sk.getOutputStream());
//                printStream.print("HTTP/1.1 400 Can not get through\r\n\r\n");
//                printStream.flush();
            } catch (IOException ioe) {

            }
        }
    }
}
